//
//  PlayerModel.m
//  TFY_PlayerView
//
//  Created by 田风有 on 2019/6/29.
//  Copyright © 2019 田风有. All rights reserved.
//

#import "PlayerModel.h"

@implementation PlayerCommand

-(void)setType:(NSInteger)type{
    _type = type;
}

-(void)setPage:(NSInteger)page{
    _page = page;
}

-(RACCommand *)picCommand{
    if (!_picCommand) {
        _picCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
            return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
                
                [TFY_NetWorking getWithUrl:GET_INDEX_KEY refreshCache:NO params:@{@"cid":@(self.type),@"page":@(self.page)} success:^(id response) {
                    
                    PlayerModel *models = [PlayerModel tfy_ModelWithJson:response];
                    
                    [subscriber sendNext:models];
                    [subscriber sendCompleted];
                } fail:^(NSError *error) {
                    [subscriber sendNext:nil];
                    [subscriber sendCompleted];
                    [TFY_ProgressHUD showErrorWithStatus:@"数据请求失败!"];
                }];
                return nil;
            }];
        }];
    }
    return _picCommand;
}

@end

@implementation Data

@end

@implementation PlayerModel
+(NSDictionary <NSString *, Class> *)tfy_ModelReplacePropertyClassMapper{
    return @{@"data":[Data class]};
}
@end
